package com.onpositive.mediawiki.deserializing;

import java.io.File;

import com.onpositive.dataminer.core.DataProviderConfig;
import com.onpositive.dataminer.core.IDataProvider;


public class SerializedStorageDataProvider implements IDataProvider {

	private DataProviderConfig config;

	public SerializedStorageDataProvider(DataProviderConfig config) {
		this.config=config;
	}

	@Override
	public DataProviderConfig getConfig() {
		return config;
	}

	@Override
	public void onUninstall() {

	}

	@Override
	public void onInstall() {

	}
	SerializedUniverse universe ;

	@Override
	public SerializedUniverse getUniverse() {
		if (universe==null){
			File providerTypeDataArea = config.getProviderTypeDataArea();
			providerTypeDataArea.mkdirs();
			String absolutePath = providerTypeDataArea.getAbsolutePath();
			universe = new SerializedUniverse( config.getUrl() ) ;
			if( universe.getCategory() == null )
				universe = null ;
		}
		return universe;
	}
	@Override
	public String toString() {
		return config.getUrl();
	}

}

